<!-- /* Description for file.
 * 面试题目-无限树页面
 *
 * @copyright     Copyright 2008-2010, PHInfo Services Inc. (http://www.phinfoservices.com)
 * @package       ues
 * @subpackage    ues/app/views/interviewquestions
 * @since         ues
 * @version       V0.0.1
 * @modifiedby    张海杰2011年0708
 * @lastmodified  张海杰2011年0709
 */-->
 
<?php
echo $html->css ( 'interviewquestions_screen' );
echo $html->css ( 'jquery.treeview' );
echo $javascript->link ( 'jquery' );
echo $javascript->link ( 'jquery-treeview/jquery.treeview' );
echo $javascript->link ( 'jquery-treeview/jquery.cookie' );
?>
<meta   http-equiv= "Refresh "   content= "2 ">
<script type="text/javascript">
	$(document).ready(function(){
		$("#browser").treeview();
	});
</script>
<div id="main_tree">
	<a href="<?php echo ROOT_WEB_PATH; ?>/interviewquestions/addtest/" target="Interview_content" class="viewpaper">
		<?php echo $html->image('add.gif', array('alt' =>  __('Add', true),'border'=>'0')); ?>&nbsp;<?php __('Interviewquestion Add');?>
	</a>
		<!--添加试卷按钮 -->
<!--树形UI_HTMl套用
	<ul id="browser" class="filetree treeview-famfamfam">
		<li class="closed"><span class="folder">  </span>
			<ul>
				<li><span class="file">  </span>
				</li>
			</ul>
		</li>
	</ul>
-->
<?php if (count($interviewquestions)>0){
		echo "	<ul id='browser' class='treeview-famfamfam'>";
			for ($i=0;$i<count($interviewquestions);$i++){
				if($interviewquestions[$i]['Interviewquestion']['fatherId']==0){
					echo '<li class="closed">';
					echo '<span class="folder">';
					echo $html->link($interviewquestions[$i]['Interviewquestion']['name'],array('action'=>'view',$interviewquestions[$i]['Interviewquestion']['id']),
					array('target'=>'Interview_content','title'=>$interviewquestions[$i]['Interviewquestion']['name']));
					echo '</span>';
					for($j=0;$j<count($datass);$j++){
						if($datass[$j]['Interviewquestion']['fatherId']==$interviewquestions[$i]['Interviewquestion']['id']){
							echo '<ul>';
							echo '<li class="closed">';
							echo '<span class="folder">';
							echo $html->link($datass[$j]['Interviewquestion']['name'],array('action'=>'viewquestion',$datass[$j]['Interviewquestion']['id']),
									array('target'=>'Interview_content','title'=>$datass[$j]['Interviewquestion']['name']));
							echo '</span>';
							echo getTree($datass,$datass[$j]['Interviewquestion']['id']);
							echo  '</li>';
							echo  '</ul>';
						}	
					}
					echo  '</li>';
				}
			}
		echo '</ul>';
//		for($k=0;$k<count($datass);$k++){
//		echo $datass[$k]['Interviewquestion']['name'];
//		echo "=======";
//		}
	}
	function getTree($datass, $pId)
	{
		$html = '';
			foreach($datass as $k => $v)
			{
			   if($v['Interviewquestion']['fatherId'] == $pId)
			   {         //父亲找到儿子
			    $html .= "<li class='closed'><span class='folder'><a target='Interview_content' href='<?php echo ROOT_WEB_PATH; ?>/interviewquestions/viewquestion/";
			    $html .=$v['Interviewquestion']['id'];
			    $html .="'>";
			    $html .=$v['Interviewquestion']['name'];
			    $html .="</a></span>";
			    $html .= getTree($datass, $v['Interviewquestion']['id']);
			    $html = $html."</li>";
			   }
			}
			return $html ? '<ul>'.$html.'</ul>' : $html ;
		}
?>
</div>